package com.code.springbootmybatismysql.controller;

import com.code.springbootmybatismysql.model.User;
import com.code.springbootmybatismysql.service.UserService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/*
 * @author: liyufei
 * @date: 2018-05-29 11:03
 */
@RestController
public class UserController {

    @Autowired
    private UserService userService;

    @GetMapping("/user/{username}")
    public User getUser(@PathVariable("username") String username) {
        return userService.getUserByUsername(username);
    }

    @PostMapping("/user")
    public void insertUser(@RequestBody User user) {
        userService.insertUser(user);
    }
}
